package com.web.servlet;

import com.web.entity.Test;
import com.web.service.Testdaoimpl;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 发送考试页面到StudentTest.jsp
 * @author 12270
 */
@WebServlet("/sttss")
public class SendTestToStudentsServlet extends HttpServlet{
    
    Testdaoimpl testdao = new Testdaoimpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        //1. 获取请求参数
        int courseid = Integer.parseInt(req.getParameter("courseid"));
        String classid = req.getParameter("classid");
        
        //2. 执行业务逻辑
        HttpSession session = req.getSession();
        session.setAttribute("courseid", courseid);
        session.setAttribute("classid", classid);
        
        List<Test> list= testdao.getOneByCourseid(courseid) ;
        
        session.setAttribute("StudentTestlist", list);

        //3. 生成响应内容
        req.getRequestDispatcher("/StudentTest.jsp").forward(req, resp);
    }
}
